package com.jsm.tf.controller;

import com.jsm.tf.entity.User;
import com.jsm.tf.request.LoginRequest;
import com.jsm.tf.response.LoginResponse;
import com.jsm.tf.service.UserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class UserController {
    @Resource
    private UserService userService;

    @PostMapping("/user/login")
    public LoginResponse login(@RequestBody  LoginRequest loginRequest){
        User user = userService.login(loginRequest.getUsername(), loginRequest.getPassword());
        return new LoginResponse(user);
    }
}
